package entries;

import java.util.*;

public class Procedure extends Entry{

	/** The amount of parameters that this procedure has */
	private int amount;
	/** A list containing all parameters for this procedure */
	private List<Parameter> parameters;
	
	/**
	 * Create a new Procedure
	 */
	public Procedure() {
		this.kind= Entry.PROCEDURE;
		this.type = Entry.VOID;
		parameters = new ArrayList<Parameter>();
		amount = 0;
	}

	/**
	 * Update the list of parameters with a new parameter
	 * @param id The name of the parameter
	 * @param type The type of the parameter
	 * @param number The number of which this parameter is (For example it is the fourth parameter that needs to be entered, then number = 4)
	 */
	public void addParameter(String id, String type, int number) {
		parameters.add(new Parameter(id, type, number));
		amount = number;
	}
	
	/**
	 * Get the type for a parameter, based on the name of the parameter
	 * @param id The name of the parameter
	 * @return The type of the parameter
	 */
	public char getParameterType(String id){
		char result = NONE;
		for(Parameter param: parameters){
			if(param.getId() == id){
				result = param.getType();
			}
		}
		return result;
	}
	
	/**
	 * Get the type for a parameter, based on the number of the parameter
	 * @param number The number of the parameter
	 * @return The type of the parameter
	 */
	public char getParameterType(int number){
		char result = NONE;
		for(Parameter param: parameters){
			if(param.getNumber() == number){
				result = param.getType();
			}
		}
		return result;
	}
	
	/**
	 * Return the amount of parameters this function has
	 * @return The amount of parameters
	 */
	public int getParamaters() { return amount; }
}